POV-Ray : Newsgroups : povray.general : remove array element after N uses? : Re: remove array element after N uses? Server Time
16 May 2024 16:24:55 EDT (-0400)
  Re: remove array element after N uses?  
From: clipka
Date: 25 Mar 2009 15:40:00
Message: <web.49ca88269fb46029c1f399840@news.povray.org>
"[GDS|Entropy]" <gds### [at] hotmailcom> wrote:
> Damn...maybe it would be seriously worth the effort of tracking down
> whatever code handles structs and dynamic lists and etc.. in the language
> that pov was written, and integrating that into povray with some nice SDL
> implementation. I'm more than sick of needing and not having those kinds of
> things.

If I wasn't working on various other pieces of POV code, that's what I'd
probably be doing right now...

(Note however that "in the language that pov was written" would mean C until
only very recently, so nowhere close to dynamic lists whatsoever; and structs,
although C does have them, would have to be represented internally using
"arrays of members" as it were, because C can't create new structs at runtime.)

> http://www.haskell.org/haskellwiki/POV-Ray_SDL_project

Yargh! Vade! >_<

> Beyond being just something that I threw together to do something like what
> I wanted, I decided that I might want to add an absurd amount of
> functionality later and that this would be the most logical way to leave my
> options open. For example I might add other related things to each of the
> dimensions, and it might be best to keep each category of data seperate.

Again, too much OO thinking for POV SDL. You can't store separate things in the
multiple dimensions of such an array anyway; and if one of your "subsections"
would need more elements, you'd need to add more elements to the other
"subsections" as well... not too bright.

But what you might want to do is:

#declare POINT  = 0;
#declare COUNT  = 1;
#declare RANDOM = 2;

#declare Array[i][POINT]  = <...>;
#declare Array[i][COUNT]  = <0,0,0>;
#declare Array[i][RANDOM] = <0,RRand(RsA, rMin, rMax),0>;

(That's basically how struct support would have to be implemented in POV
internally - except that we'd need to be able to store different things in the
array elements)

or maybe

#macro GET_POINT(a,i)
  Array[i][0]
#end

#macro GET_COUNT(a,i)
  Array[i][1].x
#end

#macro GET_RANDOM(a,i)
  Array[i][2].y
#end

> As a side note, why in the nine hells aren't there Round and VRound macros
> in pov to start with??

You can round using "int(x+0.5)", so no problem writing your own macros...

Yes, maybe the standard include files could use an overhaul, too.

> They seem kind of useful to just have been left out...then again...so do
> structs, enums, custom types, multi-datatype arrays, type casting, type
> conversion and list<T>'s...

.... and a new SDL grammar, as we're on it.

For the job we're doing, octrees would come in handy, too.

I think one of the greatest current limitations is the inability of arrays to
store elements of different types. Otherwise, structs could easily be simulated
by using identifiers holding constants, e.g.

#declare FIELD_FOO = 0
#declare FIELD_BAR = 1

#declare MyArray[FIELD_FOO] = <0,0,0>;
#declare MyArray[FIELD_BAR] = pigment { ... };

which still wouldn't be ideal, but still quite an improvement.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.